﻿@using CnGalWebSite.Components.Services;
@inject IDataCacheService _dataCacheService
@inject ImagesLargeViewService ImagesLargeViewService
@inject IEventService _eventService


<CnGalWebSite.Components.Containers.MasaTitleContainer Title="奖品" Icon="@IconType.Gift.ToIconString()" Collapable Outline>
    <div class="row">
        @foreach (var item in Model)
        {
            <div class="col-6 col-lg-4 col-xxl-3 mb-4">
                <AwardCard Model="item" OnClickImage="()=>OnClickImage(item)" />

            </div>
        }
    </div>

</CnGalWebSite.Components.Containers.MasaTitleContainer>

@code {

    [Parameter]
    public List<LotteryAwardViewModel> Model { get; set; }

    public async void OnClickImage(LotteryAwardViewModel model)
    {
        if (_dataCacheService.IsApp)
        {
            await _eventService.OpenNewPage(model.Image);
        }
        else
        {
            await ImagesLargeViewService.ViewLargeImages(Model.Select(s => new ImagesLargeViewModel
                {
                    Image = s.Image,
                    Note = s.Name
                }).ToList(), Model.IndexOf(model));
        }

    }
}
